home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / ultraman.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  13KB  |  403 lines

  1. /***************************************************************************
  2.  
  3. Ultraman (c) 1991  Banpresto / Bandai
  4.  
  5. Driver by Manuel Abadia <manu@teleline.es>
  6.  
  7. ***************************************************************************/
  8.  
  9. #include "driver.h"
  10. #include "cpu/z80/z80.h"
  11. #include "cpu/m68000/m68000.h"
  12. #include "vidhrdw/generic.h"
  13. #include "vidhrdw/konamiic.h"
  14.  
  15. unsigned char* ultraman_regs;
  16.  
  17. /* from vidhrdw/ultraman.c */
  18. int ultraman_vh_start( void );
  19. void ultraman_vh_stop( void );
  20. void ultraman_vh_screenrefresh( struct osd_bitmap *bitmap,int full_refresh );
  21.  
  22. static READ_HANDLER( ultraman_K051937_r )
  23. {
  24.     return K051937_r(offset >> 1);
  25. }
  26.  
  27. static READ_HANDLER( ultraman_K051960_r )
  28. {
  29.     return K051960_r(offset >> 1);
  30. }
  31.  
  32. static READ_HANDLER( ultraman_K051316_0_r )
  33. {
  34.     return K051316_0_r(offset >> 1);
  35. }
  36.  
  37. static READ_HANDLER( ultraman_K051316_1_r )
  38. {
  39.     return K051316_1_r(offset >> 1);
  40. }
  41.  
  42. static READ_HANDLER( ultraman_K051316_2_r )
  43. {
  44.     return K051316_2_r(offset >> 1);
  45. }
  46.  
  47. static WRITE_HANDLER( ultraman_K051316_0_w )
  48. {
  49.     if ((data & 0x00ff0000) == 0)
  50.         K051316_0_w(offset >> 1, data & 0xff);
  51. }
  52.  
  53. static WRITE_HANDLER( ultraman_K051316_1_w )
  54. {
  55.     if ((data & 0x00ff0000) == 0)
  56.         K051316_1_w(offset >> 1, data & 0xff);
  57. }
  58.  
  59. static WRITE_HANDLER( ultraman_K051316_2_w )
  60. {
  61.     if ((data & 0x00ff0000) == 0)
  62.         K051316_2_w(offset >> 1, data & 0xff);
  63. }
  64.  
  65. static WRITE_HANDLER( ultraman_K051316_ctrl_0_w )
  66. {
  67.     if ((data & 0x00ff0000) == 0)
  68.         K051316_ctrl_0_w(offset >> 1, data & 0xff);
  69. }
  70.  
  71. static WRITE_HANDLER( ultraman_K051316_ctrl_1_w )
  72. {
  73.     if ((data & 0x00ff0000) == 0)
  74.         K051316_ctrl_1_w(offset >> 1, data & 0xff);
  75.  
  76. }
  77.  
  78. static WRITE_HANDLER( ultraman_K051316_ctrl_2_w )
  79. {
  80.     if ((data & 0x00ff0000) == 0)
  81.         K051316_ctrl_2_w(offset >> 1, data & 0xff);
  82. }
  83.  
  84. static WRITE_HANDLER( ultraman_K051937_w )
  85. {
  86.     if ((data & 0x00ff0000) == 0)
  87.         K051937_w(offset >> 1, data & 0xff);
  88. }
  89.  
  90. static WRITE_HANDLER( ultraman_K051960_w )
  91. {
  92.     if ((data & 0x00ff0000) == 0)
  93.         K051960_w(offset >> 1, data & 0xff);
  94. }
  95.  
  96. static WRITE_HANDLER( ultraman_reg_w )
  97. {
  98.     int oldword = READ_WORD(&ultraman_regs[offset]);
  99.     int newword = COMBINE_WORD(oldword, data);
  100.  
  101.     WRITE_WORD(&ultraman_regs[offset],newword);
  102.  
  103.     switch (offset){
  104.         /*    bit 0: enable wraparound for scr #1
  105.             bit 1: msb of code for scr #1
  106.             bit 2: enable wraparound for scr #2
  107.             bit 3: msb of code for scr #2
  108.             bit 4: enable wraparound for scr #3
  109.             bit 5: msb of code for scr #3
  110.             bit 7: coin counter */
  111.         case 0x18:
  112.             K051316_wraparound_enable(0, data & 0x01);
  113.             K051316_wraparound_enable(1, data & 0x04);
  114.             K051316_wraparound_enable(2, data & 0x10);
  115.             coin_counter_w(0, newword & 0x80);
  116.             break;
  117.  
  118.         case 0x20:    /* sound code # */
  119.             soundlatch_w(0, newword & 0xff);
  120.             break;
  121.  
  122.         case 0x28:    /* cause interrupt on audio CPU */
  123.             cpu_cause_interrupt(1,Z80_NMI_INT);
  124.             break;
  125.  
  126.         case 0x30:    /* watchdog timer */
  127.             watchdog_reset_w(0, newword & 0xff);
  128.             break;
  129.     }
  130. }
  131.  
  132. static struct MemoryReadAddress ultraman_readmem[] =
  133. {
  134.     { 0x000000, 0x03ffff, MRA_ROM },                /* ROM */
  135.     { 0x080000, 0x08ffff, MRA_BANK1 },                /* RAM */
  136.     { 0x180000, 0x183fff, paletteram_word_r },        /* Palette */
  137.     { 0x1c0000, 0x1c0001, input_port_0_r },            /* Coins + Service */
  138.     { 0x1c0002, 0x1c0003, input_port_1_r },            /* 1P controls */
  139.     { 0x1c0004, 0x1c0005, input_port_2_r },            /* 2P controls */
  140.     { 0x1c0006, 0x1c0007, input_port_3_r },            /* DIPSW #1 */
  141.     { 0x1c0008, 0x1c0009, input_port_4_r },            /* DIPSW #2 */
  142.     { 0x204000, 0x204fff, ultraman_K051316_0_r },    /* K051316 #0 RAM */
  143.     { 0x205000, 0x205fff, ultraman_K051316_1_r },    /* K051316 #1 RAM */
  144.     { 0x206000, 0x206fff, ultraman_K051316_2_r },    /* K051316 #2 RAM */
  145.     { 0x304000, 0x30400f, ultraman_K051937_r },        /* Sprite control */
  146.     { 0x304800, 0x304fff, ultraman_K051960_r },        /* Sprite RAM */
  147.     { -1 }
  148. };
  149.  
  150. static struct MemoryWriteAddress ultraman_writemem[] =
  151. {
  152.     { 0x000000, 0x03ffff, MWA_ROM },                    /* ROM */
  153.     { 0x080000, 0x08ffff, MWA_BANK1 },                    /* RAM */
  154.     { 0x180000, 0x183fff, paletteram_xRRRRRGGGGGBBBBB_word_w, &paletteram },/* Palette */
  155.     { 0x1c0000, 0x1c0031, ultraman_reg_w, &ultraman_regs },    /* counters + sound + watchdog + gfx ctrl */
  156.     { 0x204000, 0x204fff, ultraman_K051316_0_w },        /* K051316 #0 RAM */
  157.     { 0x205000, 0x205fff, ultraman_K051316_1_w },        /* K051316 #1 RAM */
  158.     { 0x206000, 0x206fff, ultraman_K051316_2_w },        /* K051316 #2 RAM */
  159.     { 0x207f80, 0x207f9f, ultraman_K051316_ctrl_0_w    },    /* K051316 #0 registers  */
  160.     { 0x207fa0, 0x207fbf, ultraman_K051316_ctrl_1_w    },    /* K051316 #1 registers */
  161.     { 0x207fc0, 0x207fdf, ultraman_K051316_ctrl_2_w    },    /* K051316 #2 registers */
  162.     { 0x304000, 0x30400f, ultraman_K051937_w },            /* Sprite control */
  163.     { 0x304800, 0x304fff, ultraman_K051960_w },            /* Sprite RAM */
  164.     { -1 }
  165. };
  166.  
  167. static struct MemoryReadAddress ultraman_readmem_sound[] =
  168. {
  169.     { 0x0000, 0x7fff, MRA_ROM },                    /* ROM */
  170.     { 0x8000, 0xbfff, MRA_RAM },                    /* RAM */
  171.     { 0xc000, 0xc000, soundlatch_r },                /* Sound latch read */
  172.     { 0xe000, 0xe000, OKIM6295_status_0_r },        /* M6295 */
  173.     { 0xf001, 0xf001, YM2151_status_port_0_r },        /* YM2151 */
  174.     { -1 }
  175. };
  176.  
  177. static struct MemoryWriteAddress ultraman_writemem_sound[] =
  178. {
  179.     { 0x0000, 0x7fff, MWA_ROM },                    /* ROM */
  180.     { 0x8000, 0xbfff, MWA_RAM },                    /* RAM */
  181.     { 0xd000, 0xd000, MWA_NOP },                    /* ??? */
  182.     { 0xe000, 0xe000, OKIM6295_data_0_w },            /* M6295 */
  183.     { 0xf000, 0xf000, YM2151_register_port_0_w },    /* YM2151 */
  184.     { 0xf001, 0xf001, YM2151_data_port_0_w },        /* YM2151 */
  185.     { -1 }
  186. };
  187.  
  188. static struct IOWritePort ultraman_writeport_sound[] =
  189. {
  190.     { 0x00, 0x00, MWA_NOP },                        /* ??? */
  191.     { -1 }
  192. };
  193.  
  194.  
  195. INPUT_PORTS_START( ultraman )
  196.  
  197.     PORT_START    /* Coins + Service */
  198.     PORT_BIT( 0x0f, IP_ACTIVE_LOW, IPT_UNKNOWN )
  199.     PORT_BITX(0x10, IP_ACTIVE_LOW, IPT_SERVICE, DEF_STR( Service_Mode ), KEYCODE_F2, IP_JOY_NONE )
  200.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN3 )
  201.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 )
  202.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN2 )
  203.  
  204.     PORT_START    /* IN #1 */
  205.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START1 )
  206.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_UP      | IPF_8WAY | IPF_PLAYER1 )
  207.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER1 )
  208.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER1 )
  209.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER1 )
  210.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
  211.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 )
  212.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER1 )
  213.  
  214.     PORT_START    /* IN #2 */
  215.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START2 )
  216.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_UP      | IPF_8WAY | IPF_PLAYER2 )
  217.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER2 )
  218.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER2 )
  219.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER2 )
  220.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
  221.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
  222.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER2 )
  223.  
  224.     PORT_START    /* DSW #1 */
  225.     PORT_DIPNAME( 0x0f, 0x0f, DEF_STR( Coin_A ) )
  226.     PORT_DIPSETTING(    0x02, DEF_STR( 4C_1C ) )
  227.     PORT_DIPSETTING(    0x05, DEF_STR( 3C_1C ) )
  228.     PORT_DIPSETTING(    0x08, DEF_STR( 2C_1C ) )
  229.     PORT_DIPSETTING(    0x04, DEF_STR( 3C_2C ) )
  230.     PORT_DIPSETTING(    0x01, DEF_STR( 4C_3C ) )
  231.     PORT_DIPSETTING(    0x0f, DEF_STR( 1C_1C ) )
  232.     PORT_DIPSETTING(    0x03, DEF_STR( 3C_4C ) )
  233.     PORT_DIPSETTING(    0x07, DEF_STR( 2C_3C ) )
  234.     PORT_DIPSETTING(    0x0e, DEF_STR( 1C_2C ) )
  235.     PORT_DIPSETTING(    0x06, DEF_STR( 2C_5C ) )
  236.     PORT_DIPSETTING(    0x0d, DEF_STR( 1C_3C ) )
  237.     PORT_DIPSETTING(    0x0c, DEF_STR( 1C_4C ) )
  238.     PORT_DIPSETTING(    0x0b, DEF_STR( 1C_5C ) )
  239.     PORT_DIPSETTING(    0x0a, DEF_STR( 1C_6C ) )
  240.     PORT_DIPSETTING(    0x09, DEF_STR( 1C_7C ) )
  241.     PORT_DIPSETTING(    0x00, DEF_STR( Free_Play ) )
  242.  
  243.     PORT_DIPNAME( 0xf0, 0xf0, DEF_STR( Coin_B ) )
  244.     PORT_DIPSETTING(    0x20, DEF_STR( 4C_1C ) )
  245.     PORT_DIPSETTING(    0x50, DEF_STR( 3C_1C ) )
  246.     PORT_DIPSETTING(    0x80, DEF_STR( 2C_1C ) )
  247.     PORT_DIPSETTING(    0x00, DEF_STR( 5C_3C ) )
  248.     PORT_DIPSETTING(    0x40, DEF_STR( 3C_2C ) )
  249.     PORT_DIPSETTING(    0x10, DEF_STR( 4C_3C ) )
  250.     PORT_DIPSETTING(    0xf0, DEF_STR( 1C_1C ) )
  251.     PORT_DIPSETTING(    0x30, DEF_STR( 3C_4C ) )
  252.     PORT_DIPSETTING(    0x70, DEF_STR( 2C_3C ) )
  253.     PORT_DIPSETTING(    0xe0, DEF_STR( 1C_2C ) )
  254.     PORT_DIPSETTING(    0x60, DEF_STR( 2C_5C ) )
  255.     PORT_DIPSETTING(    0xd0, DEF_STR( 1C_3C ) )
  256.     PORT_DIPSETTING(    0xc0, DEF_STR( 1C_4C ) )
  257.     PORT_DIPSETTING(    0xb0, DEF_STR( 1C_5C ) )
  258.     PORT_DIPSETTING(    0xa0, DEF_STR( 1C_6C ) )
  259.     PORT_DIPSETTING(    0x90, DEF_STR( 1C_7C ) )
  260.  
  261.     PORT_START    /* DSW #2 */
  262.     PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
  263.     PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
  264.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  265.     PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
  266.     PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
  267.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  268.     PORT_DIPNAME( 0x04, 0x04, "Allow Continue" )
  269.     PORT_DIPSETTING(    0x00, DEF_STR( No ) )
  270.     PORT_DIPSETTING(    0x04, DEF_STR( Yes ) )
  271.     PORT_DIPNAME( 0x08, 0x00, DEF_STR( Demo_Sounds ) )
  272.     PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
  273.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  274.     PORT_DIPNAME( 0x30, 0x30, DEF_STR( Difficulty ) )
  275.     PORT_DIPSETTING(    0x10, "Easy" )
  276.     PORT_DIPSETTING(    0x30, "Normal" )
  277.     PORT_DIPSETTING(    0x20, "Difficult" )
  278.     PORT_DIPSETTING(    0x00, "Very Difficult" )
  279.     PORT_DIPNAME( 0x40, 0x40, "Upright Controls" )
  280.     PORT_DIPSETTING(    0x40, "Single" )
  281.     PORT_DIPSETTING(    0x00, "Dual" )
  282.     PORT_DIPNAME( 0x80, 0x00, DEF_STR( Cabinet ) )
  283.     PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
  284.     PORT_DIPSETTING(    0x80, DEF_STR( Cocktail ) )
  285. INPUT_PORTS_END
  286.  
  287.  
  288.  
  289. static struct YM2151interface ym2151_interface =
  290. {
  291.     1,
  292.     24000000/6,    /* 4 MHz (tempo verified against real board) */
  293.     { YM3012_VOL(100,MIXER_PAN_LEFT,100,MIXER_PAN_RIGHT) },
  294.     { 0 },
  295. };
  296.  
  297. static struct OKIM6295interface okim6295_interface =
  298. {
  299.     1,                    /* 1 chip */
  300.     { 8000 },            /* 8KHz? */
  301.     { REGION_SOUND1 },    /* memory region */
  302.     { 50 }
  303. };
  304.  
  305.  
  306.  
  307. static struct MachineDriver machine_driver_ultraman =
  308. {
  309.     /* basic machine hardware */
  310.     {
  311.         {
  312.             CPU_M68000,
  313.             24000000/2,        /* 12 MHz? */
  314.             ultraman_readmem,ultraman_writemem,0,0,
  315.             m68_level4_irq,1
  316.         },
  317.         {
  318.             CPU_Z80,
  319.             24000000/6,        /* 4 MHz? */
  320.             ultraman_readmem_sound, ultraman_writemem_sound,0,ultraman_writeport_sound,
  321.             ignore_interrupt,1    /* NMI triggered by the m68000 */
  322.         }
  323.     },
  324.     60,DEFAULT_REAL_60HZ_VBLANK_DURATION,
  325.     10,
  326.     0,
  327.  
  328.     /* video hardware */
  329.     64*8, 32*8, { 14*8, (64-14)*8, 2*8, 30*8-1 },
  330.     0,    /* decoded by KonamiIC */
  331.     8192, 8192,
  332.     0,
  333.  
  334.     VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE,
  335.     0,
  336.     ultraman_vh_start,
  337.     ultraman_vh_stop,
  338.     ultraman_vh_screenrefresh,
  339.  
  340.     /* sound hardware */
  341.     SOUND_SUPPORTS_STEREO,0,0,0,
  342.     {
  343.         {
  344.             SOUND_YM2151,
  345.             &ym2151_interface
  346.         },
  347.         {
  348.             SOUND_OKIM6295,
  349.             &okim6295_interface
  350.         }
  351.     }
  352.  
  353. };
  354.  
  355.  
  356.  
  357. ROM_START( ultraman )
  358.     ROM_REGION( 0x040000, REGION_CPU1 )    /* 68000 code */
  359.     ROM_LOAD_EVEN(    "910-b01.c11",    0x000000, 0x020000, 0x3d9e4323 )
  360.     ROM_LOAD_ODD(    "910-b02.d11",    0x000000, 0x020000, 0xd24c82e9 )
  361.  
  362.     ROM_REGION( 0x010000, REGION_CPU2 )    /* Z80 code */
  363.     ROM_LOAD( "910-a05.d05",    0x00000, 0x08000, 0xebaef189 )
  364.  
  365.     ROM_REGION( 0x100000, REGION_GFX1 )    /* Sprites */
  366.     ROM_LOAD( "910-a19.l04",    0x000000, 0x080000, 0x2dc9ffdc )
  367.     ROM_LOAD( "910-a20.l01",    0x080000, 0x080000, 0xa4298dce )
  368.  
  369.     ROM_REGION( 0x080000, REGION_GFX2 )    /* BG 1  */
  370.     ROM_LOAD( "910-a07.j15",    0x000000, 0x020000, 0x8b43a64e )
  371.     ROM_LOAD( "910-a08.j16",    0x020000, 0x020000, 0xc3829826 )
  372.     ROM_LOAD( "910-a09.j18",    0x040000, 0x020000, 0xee10b519 )
  373.     ROM_LOAD( "910-a10.j19",    0x060000, 0x020000, 0xcffbb0c3 )
  374.  
  375.     ROM_REGION( 0x080000, REGION_GFX3 ) /* BG 2 */
  376.     ROM_LOAD( "910-a11.l15",    0x000000, 0x020000, 0x17a5581d )
  377.     ROM_LOAD( "910-a12.l16",    0x020000, 0x020000, 0x39763fb5 )
  378.     ROM_LOAD( "910-a13.l18",    0x040000, 0x020000, 0x66b25a4f )
  379.     ROM_LOAD( "910-a14.l19",    0x060000, 0x020000, 0x09fbd412 )
  380.  
  381.     ROM_REGION( 0x080000, REGION_GFX4 ) /* BG 3 */
  382.     ROM_LOAD( "910-a15.m15",    0x000000, 0x020000, 0x6d5bfbb7 )
  383.     ROM_LOAD( "910-a16.m16",    0x020000, 0x020000, 0x5f6f8c3d )
  384.     ROM_LOAD( "910-a17.m18",    0x040000, 0x020000, 0x1f3ec4ff )
  385.     ROM_LOAD( "910-a18.m19",    0x060000, 0x020000, 0xfdc42929 )
  386.  
  387.     ROM_REGION( 0x0100, REGION_PROMS )
  388.     ROM_LOAD( "910-a21.f14",    0x000000, 0x000100, 0x64460fbc )    /* priority encoder (not used) */
  389.  
  390.     ROM_REGION( 0x040000, REGION_SOUND1 )    /* M6295 data */
  391.     ROM_LOAD( "910-a06.c06",    0x000000, 0x040000, 0x28fa99c9 )
  392. ROM_END
  393.  
  394.  
  395.  
  396. static void init_ultraman(void)
  397. {
  398.     konami_rom_deinterleave_2(REGION_GFX1);
  399. }
  400.  
  401.  
  402. GAME( 1991, ultraman, 0, ultraman, ultraman, ultraman, ROT0, "Banpresto/Bandai", "Ultraman (Japan)" )
  403.